import java.util.Scanner;

public class Main {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < a.length - 1; i++) {
            for(int j = i+1; j < a.length; j++) {
                if(min > Math.abs(a[i] + a[j] - k) ) {
                    min = Math.abs(a[i] + a[j] - k);
                }
            }
        }
        int count = 0;
        for(int i = 0; i < a.length - 1; i++) {
            for(int j = i+1; j < a.length; j++) {
                if(min == Math.abs(a[i] + a[j] - k) ) {
                    count++;
                }
            }
        }
        System.out.println(min + " " + count);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        boolean flg = true;
        int count = 0;
        while(flg) {
            int i = 0;
            for(; i < n; i++) {
                if(a[i] != k) {
                    break;
                }
            }
            while(a[i] != k) {
                i++;
            }
            int cur = i - k + 1;
            for(int j = cur; j <= i; j++) {
                if(a[j] != a[i]) {
                    a[j] = a[i];
                    count++;
                }
            }
            int q = 0;
            for(; q < n; q++) {
                if(a[q] != a[i]) {
                    break;
                }
            }
            if(q == n) {
                flg = false;
            }
        }
        System.out.println(count);
    }
}
